package views
{
	import assets.Asset;
	
	import away3d.lights.LightProbe;
	import away3d.primitives.SkyBox;
	
	import events.LoadedEvent;
	
	public class EnvLight extends LightProbe
	{
		private var _mapURL:String;
		
		public function EnvLight(mapName:String)
		{
			super(null, null);
			
			_mapURL = Global.assetPath+"textures/"+mapName+".zip";
			
			Asset.atfTextureWithZIP.addEventListener(LoadedEvent.TEXTURE_COMPLETE,onMapLoaded);
			Asset.atfTextureWithZIP.load(_mapURL,true);
		}
		
		private function onMapLoaded(e:LoadedEvent):void
		{
			if(e.URL==_mapURL)
			{
				Asset.atfTextureWithZIP.removeEventListener(LoadedEvent.TEXTURE_COMPLETE,onMapLoaded);
				diffuseMap = Asset.resAtfTextures[_mapURL];
			}
		}
	}
}